﻿using DAL.Repositories;
using Data.MyDbContext;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class UnitOfRepositories : IUnitOfRepositories
    {
        private readonly DbContextFactory _dbfactory = null;
        public UnitOfRepositories(DbContextFactory dbfactory)
        {
            if (dbfactory == null) throw new ArgumentNullException("dbfactory cannot be null...");
            _dbfactory = dbfactory;
        
        }

        private CategoryRepository _categoryRepo = null;
        public CategoryRepository CategoryRepo
        {
            get
            {
                if (_categoryRepo == null)
                {
                    _categoryRepo = new CategoryRepository(_dbfactory);
                }
                return _categoryRepo;
            }
        }

        private UserRepository _userRepo = null;
        public UserRepository UserRepo
        {
            get
            {
                if (_userRepo == null)
                {
                    _userRepo = new UserRepository(_dbfactory);
                }
                return _userRepo;
            }
        }

        

        private WebsiteRepository _websiteRepo = null;
        public WebsiteRepository WebsiteRepo
        {
            get
            {
                if (_websiteRepo == null)
                {
                    _websiteRepo = new WebsiteRepository(_dbfactory);
                }
                return _websiteRepo;
            }
        }
    }
}
